package com.jwd.config

import org.springframework.web.context.request.RequestContextHolder
import org.springframework.web.context.request.ServletRequestAttributes
import org.springframework.web.context.request.ServletWebRequest
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter
import javax.servlet.ServletContext
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

/**
 * Created by udi on 2017.3.4.
 */
object HttpContext {

    @JvmStatic
    val Request: HttpServletRequest
        get() {
            return (RequestContextHolder.getRequestAttributes() as ServletRequestAttributes?)?.request!!
        }

    @JvmStatic
    val Response: HttpServletResponse
        get() {
            return (RequestContextHolder.getRequestAttributes() as ServletWebRequest?)?.response!!
        }

    @JvmStatic
    val ServletContext: ServletContext
        get() {
            return Request.servletContext!!
        }
}